﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Hartley.ApplicationLogic;
using Hartley.DTOs;
using System.IO;
namespace WebApplication1
{
    public partial class viewMember : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string memId = Request.QueryString.ToString();
            MemberAL memberAL = new MemberAL();
            if (memId != "")
            {
                MemberDTO membr = memberAL.GetMemberById(new Guid(memId)).FirstOrDefault();
                //lblMemberFirstName.Text = membr.SingleOrDefault().FullName;
                //lblMemberDOB.Text = membr.SingleOrDefault().DateOfBirth.ToString();
               // txtViewMemberPermAdd.Text = membr.SingleOrDefault().PermanantAddress;
                memberProfile.InnerHtml = membr.FirstName.Length != 0 ? membr.FirstName + "'s Profile" : "Member Profile";
                memberfullname.InnerHtml = membr.FullName.Length != 0 ? membr.FullName : "N/A";
                memberBirthday.InnerHtml = membr.DateOfBirth.ToString().Length != 0 ? String.Format("{0:ddd, MMM d, yyyy}", membr.DateOfBirth) : "N/A";
                memberPermAdress.InnerHtml = membr.PermanantAddress.Length != 0 ? membr.PermanantAddress : "N/A";
                memberDesc.InnerHtml = membr.Description.Length != 0 ? membr.Description : "";
                memberDesignation.InnerHtml = membr.Designation.Length != 0 ? membr.Designation : "N/A";
                memberCompany.InnerHtml = membr.WorkingAt.Length != 0 ? membr.WorkingAt : "N/A";
                memberMobile.InnerHtml = membr.TelePhoneNo.Length != 0 ? membr.TelePhoneNo : "N/A";
                memberPostalAddress.InnerHtml = membr.TemporaryAddress.Length != 0 ? membr.TemporaryAddress : "N/A";
                memberEmail.InnerHtml = membr.Email.Length != 0 ? membr.Email : "N/A";
                memberColMembrNo.InnerHtml = membr.LifeMemberNo.Length != 0 ? membr.LifeMemberNo : "N/A";
                memberOLBatch.InnerHtml = membr.OrdinaryBatchYear.Length != 0 ? membr.OrdinaryBatchYear : "N/A";
                memberDivision.InnerHtml = membr.Division.Length != 0 ? membr.Division : "N/A";
                memberIndexNo.InnerHtml = membr.SchoolIndexNo.Length != 0 ? membr.SchoolIndexNo : "N/A";
                memberCollegeJoin.InnerHtml = membr.StudiedFrom.Length != 0 ? membr.StudiedFrom : "N/A";
                memberCollegeLeft.InnerHtml = membr.StudiedUpto.Length != 0 ? membr.StudiedUpto : "N/A";
                memberHouse.InnerHtml = membr.House.Length != 0 ? membr.House : "N/A";

                if (membr.PhotoPath != null)
                {
                    
                    if (File.Exists(Server.MapPath("~/memberPhotos/" + membr.PhotoPath)))
                    {
                        memberPhoto.Src = "memberPhotos/" + membr.PhotoPath;
                    }
                    else
                    {
                        memberPhoto.Src = "memberPhotos/noImageAvailable.jpg";
                    }
                }
                else
                {
                    memberPhoto.Src = "memberPhotos/noImageAvailable.jpg";
                }
            }
           
        }
    }
}
